import request from '@/utils/request'

export function checkUsername(username) {
  return request({
    url: '/user/check/username',
    method: 'get',
    params: { username }
  })
}

export function checkUserCom(username) {
  return request({
    url: '/user/check/com',
    method: 'get',
    params: { username }
  })
}

export function register(data) {
  return request({
    url: '/user/register',
    method: 'post',
    data
  })
}

export function login(data) {
  return request({
    url: '/user/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: { token }
  })
}

export function getDetail(id) {
  return request({
    url: '/user/detail',
    method: 'get',
    params: { id }
  })
}

export function getOrgMemberOptions() {
  return request({
    url: '/user/orgMemberOptions',
    method: 'get'
  })
}

export function getHrList(params) {
  return request({
    url: '/user/list/cid',
    method: 'get',
    params
  })
}

export function logout() {
  return request({
    url: '/user/logout',
    method: 'post'
  })
}

export function updateUserBasicInfo(data) {
  return request({
    url: '/user/update/info',
    method: 'post',
    data
  })
}

export function resetPassword(data) {
  return request({
    url: '/user/resetPassword',
    method: 'post',
    data
  })
}

export function updateAvatar(data) {
  return request({
    url: '/user/update/avatar',
    method: 'post',
    data
  })
}

export function addHrRoleToUserByName(data) {
  return request({
    url: '/user/update/role/hr',
    method: 'post',
    data
  })
}

export function deleteHrRoleToUserByName(data) {
  return request({
    url: '/user/delete/role/hr',
    method: 'post',
    data
  })
}
